package com.situ.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bean.Customers;
import com.service.ICustomerService;
import com.situ.mapper.CustomersMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomersService implements ICustomerService {
  @Autowired
    CustomersMapper customersMapper;

    @Override
    public Customers insert(Customers customers) {


       customersMapper.insert(customers);
       return customersMapper.selectById(customers.getId());

    }

    @Override
    public Customers update(Customers customers) {

        customersMapper.update(customers,null);

        return customersMapper.selectById(customers.getId());

    }

    @Override
    public Customers getById(Integer id) {

        return customersMapper.selectById(id);

    }

    @Override
    public int deleteById(Integer id) {

        return customersMapper.deleteById(id);

    }

    @Override
    public List<Customers> getListByPage(IPage page, Customers customers) {
        Wrapper wrapper=new QueryWrapper(customers);
        return customersMapper.selectList(page,wrapper);

    }

    @Override
    public List<Customers> getList(Customers customers) {

        Wrapper wrapper=new QueryWrapper(customers);
        List<Customers> list = customersMapper.selectList(wrapper);
        return list;
    }
}
